﻿using UnityEngine;

namespace FlowControl
{
    class FlowLoadInitAsset : FlowBase
    {
        public override void Activate()
        {
            base.Activate();
            ZEventCenter.AddEventListener(ConstData.COMPLETE, OnComplete);
            LoadBoardMgr.GetSingleton().Reset();
            LoadBoardMgr.GetSingleton().SetDescri(GlobalString.initAss);
            LoadBoardMgr.GetSingleton().Show();
            ZMgr.ResourceMgr.LoadResByInterfaceScene(Application.loadedLevelName);
        }

        public override void FlowUpdate(float duringTime)
        {
            base.FlowUpdate(duringTime);
            LoadBoardMgr.GetSingleton().SetPercent(ZMgr.ResourceMgr.LoadProgress);
        }

        private void OnComplete(ZEvent ev)
        {
            ZEventCenter.RemoveEventListener(ConstData.COMPLETE, OnComplete);
            IsComplete = true; ZMgr.SceneMgr.Init();
        }
    }
}